<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/11/2
 * Time: 16:11
 */

namespace app\api\model;


class CardVideo extends BaseModel
{
    protected $hidden=['from','create_time','delete_time'];

    public function getUrlAttr($value,$data){
        return $this->prefixVideo($value,$data);
    }

    /**
     * 创建视频
     * @param $info
     * @return $this
     */
    public static function createImg($info)
    {
        $data = [
            'name'=>$info->fname,
            'url'=>$info->fkey,
            'key'=>$info->fkey,
            'from'=>2,
             'w_id'=> $info->uid
        ];
        $num =  (new CardVideo())->insertGetId($data);
        $result = self::get($num);
        return $result;
    }
    /**
     * 获取视频
     * @param $img_id
     * @return null|static
     */
    public static function getImg($img_id){
        return self::get($img_id);
    }
    /**
     * 删除视频
     * @param $img_id
     * @return int
     */
    public static function deleteImg($img_id){
        return self::destroy($img_id);
    }

    /**
     * 获取视频信息
     * @param $w_id
     * @return array|false|\PDOStatement|string|\think\Model
     */
    public static function getVideoInfo($w_id){
        return self::where('w_id','=',$w_id)->find();
    }

}